﻿using System;

namespace _03_AbstractFactory
{
    class Program
    {
        /// <summary>
        /// 抽象工厂
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //制作美国手机
            IAbstractFactory americanFactory = new AmericanFactory();
            americanFactory.MadePhoneSize().MadeSize();
            americanFactory.MadePhoneColor().MadeColor();
            //制作中国手机
            IAbstractFactory chineseFactory = new ChineseFactory();
            chineseFactory.MadePhoneSize().MadeSize();
            chineseFactory.MadePhoneColor().MadeColor();
            Console.ReadKey(); 
            //如果做巴基斯坦手机呢？
        }
    }
    //工厂接口
    public interface IAbstractFactory
    {
        IPhoneSize MadePhoneSize();
        IPhoneColor MadePhoneColor();
    }
    public interface IPhoneSize
    {
        void MadeSize();
    }
    public interface IPhoneColor
    {
        void MadeColor();
    }
    public class AmericanFactory : IAbstractFactory
    {
        public IPhoneColor MadePhoneColor()
        {
            return new AmericanPhoneColor();
        }

        public IPhoneSize MadePhoneSize()
        {
            return new AmericanPhoneSize();
        }
    }
    public class ChineseFactory : IAbstractFactory
    {
        public IPhoneColor MadePhoneColor()
        {
            return new ChinesePhoneColor();
        }

        public IPhoneSize MadePhoneSize()
        {
            return new ChinesePhoneSize();
        }
    }
    public class AmericanPhoneSize : IPhoneSize
    {
        public void MadeSize()
        {
            Console.WriteLine("美国手机大小制作好了");
        }
    }
    public class ChinesePhoneSize : IPhoneSize
    {
        public void MadeSize()
        {
            Console.WriteLine("中国手机大小制作好了");
        }
    }
    public class AmericanPhoneColor : IPhoneColor
    {
        public void MadeColor()
        {
            Console.WriteLine("美国手机颜色制作好了");
        }
    }
    public class ChinesePhoneColor : IPhoneColor
    {
        public void MadeColor()
        {
            Console.WriteLine("中国手机颜色制作好了");
        }
    }
}
